<%@page import="com.baoyanghui.common.Constants"%>
<%@page import="com.baoyanghui.common.Utils"%>
<%@page import="com.baoyanghui.common.DataChanger"%>
<%@page import="com.baoyanghui.config.Configs"%>
<%@page import="java.util.HashMap"%>
<%@page import="java.util.Map"%>
<%@page import="com.baoyanghui.model.Merchant"%>
<%@page import="net.sf.json.JSONObject"%>
<%@page import="com.baoyanghui.common.InterfaceAccess"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
	if (Utils.empty((String)request.getSession().getAttribute(Configs.SESSION_USER_ID))
			|| (Constants.USER_TYPE_CUSTOMER == (Integer)request.getSession().getAttribute(Configs.SESSION_USER_TYPE))) {
		response.getWriter().print("<script type='text/javascript'>\n");
		response.getWriter().print("window.location.href='" + request.getContextPath() + "/index.jsp';\n");
		response.getWriter().print("</script>\n");
		response.getWriter().flush();
		return;
	}
%>
<% 
	String errorMessage = (String)session.getAttribute("error_message"); 
	session.removeAttribute("error_message");
	
	JSONObject profile = null;
	Merchant merchant = null;
	Map<String, String> params = new HashMap<String, String>();
	
	try {
		request.setCharacterEncoding("UTF-8");
		params.put("merchant_id", (String)session.getAttribute(Configs.SESSION_USER_ID));
		params.put("usercode", (String)session.getAttribute(Configs.SESSION_USERCODE));
		
		profile = InterfaceAccess.callInterface("/merchant/get_profile", params);
		merchant = DataChanger.getMerchant(profile);
		
		if (merchant == null) {
			return;
		}
	} catch (Exception e) {
		return;
	}
%>
<script type="text/javascript" src="../js/register.js"></script>
<script type="text/javascript" src="../js/merchant_basic_info.js"></script>
<div style="height: 34px; padding-left: 20px; padding-top: 5px; border-bottom: 1px solid gray;">
	<img class="pointer fade_effect" src="../image/btn_basic_info_on.png"/>
	<img class="pointer fade_effect" src="../image/btn_place_manage_off.png" onclick="showPlaceList();"/>
	<img class="pointer fade_effect" src="../image/btn_place_request_auth_off.png" onclick="showPlaceRequests();"/>
</div>
<div id="div_form_content">
	<form  style="margin-top: 30px;">
		<div style="width: 500px; float: left; line-height: 50px; margin-left: 20px;">
			<label>*商户ID：</label><input type="text" disabled="disabled" value="<%= merchant.getUserid() %>"/><br/>
			<label>*密码：</label><input type="password" disabled="disabled" value="******"/>
			<a class="blue" href="javascript: showChangePwd();">更改</a><br/>
			<label>*邮箱：</label><input type="text" disabled="disabled" value="<%= merchant.getEmail() %>"/>
			<a class="blue">更改</a><br/>
			<label>*公司名称：</label><input type="text" name="corporation_name" id="corporation_name" 
				maxlength="50" onblur="checkCorporationName(this.value);" value="<%= merchant.getCorporationName() %>"/><br/>
			<label>*固定电话：</label><input type="text" name="office_phone" id="office_phone" maxlength="20" 
				onblur="checkOfficePhone(this.value);" value="<%= merchant.getOfficeTel() %>"/><br/>
			<label>手机号：</label><input type="text" name="mobile" id="mobile" maxlength="20" value="<%= merchant.getMobile() %>"/><br/>
		</div>
		<div style="width: 400px; float: left;">
			<object id="flash_upload" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540002"
				type="application/x-shockwave-flash" width="119" height="34">
			  <param name="movie" value="<%= request.getContextPath() %>/flash/upload.swf?ws_context=<%= InterfaceAccess.InterfaceContext %>" />
			  <param name="quality" value="high" />
			  <param name="wmode" value="transparent"/>
			  <embed src="<%= request.getContextPath() %>/flash/upload.swf?ws_context=<%= InterfaceAccess.InterfaceContext %>" 
			  	wmode="transparent" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" 
			  	allowScriptAccess="sameDomain" allowFullScreen="false"
			  	type="application/x-shockwave-flash" width="119" height="34">
			  </embed>
			</object><br/>
<%
	if (merchant.getPhotos() != null && merchant.getPhotos().size() > 0) {
%>
			<img id="img_merchant" src="<%= InterfaceAccess.InterfaceContext + "/" + merchant.getPhotos().get(0) %>" width="165px" height="90px"/><br/>
<%
	} else {
%>
			<img id="img_merchant" src="" width="165px" height="90px"/><br/>
<%
	}
%>
			<label style="text-align: left; margin-top: 15px;">商家简介：</label><br/>
			<textarea rows="5" name="introduction" id="introduction"><%= merchant.getIntroduction() %></textarea><br/>
		</div>
		<div style="clear: both;"></div>
		<div align="left" style="margin-left: 350px; margin-top: 35px;">
			<input type="hidden" id="image_name" name="image_name"/>
			<img class="fade_effect" src="<%= request.getContextPath() %>/image/btn_save_setting.png"
				onclick="modifyBasicInfo();" style="margin-top: 10px; cursor: pointer;"/><br/>
		</div>
		<span id="error_message"><%= errorMessage == null ? "" : errorMessage %></span>
	</form>
</div>